﻿using CSharpDesign.DAL;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace CSharpDesign.BLL
{
    public class ShoppingService
    {
        SqlConnection sqlconn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
        SqlHelper data = new SqlHelper();
        //
        // TODO: 在此处添加构造函数逻辑
        //
        public string GetMoney(string username, SqlHelper data, SqlDataReader dr1)
        {
            if (dr1.Read())
            {

                string sqlstrtprice = "select sum(SPPrice*shuliang) as tprice from DingDan"
                    + " where OrderMember='" + username + "' and IsCheckout='否'";

                SqlDataReader dr;
                dr = data.GetDataReader(sqlstrtprice);
                dr.Read();
                string v = Convert.ToString(float.Parse(dr["tprice"].ToString()));

                return v;

            }
            else
            {

                return "0";

            }
        }
        public void deleteDingdan(string username)
        {
            string sqlstr = "delete from DingDan where OrderMember='"
                        + username + "' and IsCheckout='否'";
            data.RunSql(sqlstr);
        }
        public void deleteById(object RowIndex)
        {
            string sqlstr = "delete from DingDan where id='" + RowIndex + "'";
            data.RunSql(sqlstr);
        }

    }
}